package com.secretum;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;

import com.secretum.zebedee.ZBDException;
import com.secretum.zebedee.ZBDParseException;
import com.secretum.zebedee.ZBDTunnelInfoList;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

public class Secretum {

	private JFrame frmSecretum;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Secretum window = new Secretum();
					window.frmSecretum.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Secretum() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmSecretum = new JFrame();
		frmSecretum.setTitle("Secretum");
		frmSecretum.setBounds(100, 100, 347, 508);
		frmSecretum.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JButton btnNewButton = new JButton("Conectar");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// Conectar VPN 
				
			
					//Zebedee master = new Zebedee();
					//master.logger.error(e.toString());
					
					ZebedeeClient  zbd = new ZebedeeClient() ; 
					
					
					zbd.serverHost = "200.181.60.228" ; 
					zbd.privateKey = "3d57385c53f4fc8d4930ef442b1b0076786f67d0" ;
					zbd.serverMode = false ;  
					zbd.verbosity = 2  ;
					zbd.detached = true ;  
	
					ZBDTunnelInfoList tunnelInfoList = new ZBDTunnelInfoList();
					
					try {
						
						tunnelInfoList.add("7700:172.16.1.1:443");
						tunnelInfoList.add("7701:172.16.1.5:3389");
						tunnelInfoList.add("7702:172.16.1.1:443");
						
					} catch (ZBDParseException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					//	System.out.print(e.toString()) ;
					} 
					
					
					zbd.tunnelInfoList =  tunnelInfoList ; 
					
					try {
						
						zbd.execute() ;
						
					} catch (Exception e) {
						
						System.out.print(e.toString()) ;
						
					} 
				
				
				 
								
				 
				
				
				
			}
		});
		
		JPanel panel = new JPanel();
		GroupLayout groupLayout = new GroupLayout(frmSecretum.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(panel, GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
						.addComponent(btnNewButton))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(panel, GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(btnNewButton)
					.addContainerGap())
		);
		frmSecretum.getContentPane().setLayout(groupLayout);
		
		JMenuBar menuBar = new JMenuBar();
		frmSecretum.setJMenuBar(menuBar);
		
		JMenu mnArquivo = new JMenu("File");
		menuBar.add(mnArquivo);
		
		JMenuItem mntmNewMenuItem = new JMenuItem("Exit");
		mnArquivo.add(mntmNewMenuItem);
		
		JMenu mnNewMenu_1 = new JMenu("Import");
		menuBar.add(mnNewMenu_1);
		
		JMenu mnHelp = new JMenu("Help");
		menuBar.add(mnHelp);
		
		JMenuItem mntmAbout = new JMenuItem("About");
		mnHelp.add(mntmAbout);
	}
}
